module eeprom_rw_top (
    input               IN_CLK_50M,
    input   [7:1]       PB,
    output              LED,
    inout               SDA,
    inout               SCL
);

parameter       SLAVE_ADDR = 7'b1010_000;  
parameter       IIC_F100K = 10'd500;            //100K-500
parameter       IIC_F400K = 10'd125;            //400K-125

//pll
wire        locked, sys_rst_n;
wire        sys_clk_50m;

// PLL pll_inst
// (
//     .clk_out1(sys_clk_50m),
//     .reset(1'b0),
//     .locked(locked), 
//     .clk_in1(IN_CLK_50M)
// );
assign sys_clk_50m = IN_CLK_50M;
assign locked = 1'b1;

assign sys_rst_n =  locked;

//key_filter
wire    [7:1]   pb_flag;


key_filter  key_filter_inst (
    .clk(sys_clk_50m),
    .rst_n(sys_rst_n),
    .pb(PB),
    .pb_flag(pb_flag),
    .us_p(),
    .ms_p(),
    .s_p()
);

//eeprom_i2c_ctrl
wire      [1:0]   cmd;
wire      [7:0]   wr_data;
wire      [15:0]  addr;
wire      [6:0]   device_addr;
wire              done;
wire      [7:0]   rd_data;

eeprom_i2c_ctrl # (
    .SLAVE_ADDR     (SLAVE_ADDR)
)
eeprom_i2c_ctrl_inst (
    .clk_50m(sys_clk_50m),
    .rst_n(sys_rst_n),
    .pb_flag(pb_flag[5]),
    .cmd(cmd),
    .wr_data(wr_data),
    .addr(addr),
    .device_addr(device_addr),
    .led(LED),
    .done(done),
    .rd_data(rd_data)
);

//eeprom_i2c_phy
eeprom_i2c_phy # (
    .IIC_F100K (IIC_F100K),            //100K-500
    .IIC_F400K (IIC_F400K)            //100K-500
)
eeprom_i2c_phy_inst (
    .clk_50m(sys_clk_50m),
    .rst_n(sys_rst_n),
    .cmd(cmd),
    .wr_data(wr_data),
    .addr(addr),
    .device_addr(device_addr),
    .done(done),
    .rd_data(rd_data),
    .SDA(SDA),
    .SCL(SCL)
);

endmodule